<?php
/**
 * Func   首页上获取彩种信息数据
 */
defined('IN_YuLin') || exit('NO PERMIT!');
include_once (ROOT_PATH.'lib/api_common/member.inc.php');

$operation = NoBadStr($_REQUEST['operation']);
if (!$operation){
    // 如果没有找到操作标识，尝试从对象信息获取
    $post = json_decode($_POST['data']);
    if($post){
        $operation = $post->operation;
    }
}
$res       = '';
$param     = array('uid' => $_uid);
switch ($operation){
    case 'bet_record':
        $res              = getOrderData($param);
        break;
    case 'itemmore':
        $param['oid']     = NoBadStr($_REQUEST['oid']);
        $res              = getOrderItemInfo($param);
        break;
    case 'chase_single_period':
        // 获取追号记录中单个期号的信息（追号记录->某个追号信息->单个期号）
        $param['period']  = NoBadStr($_REQUEST['period_id']);
        $param['lott_id'] = NoBadStr($_REQUEST['lott_id']);
        $res              = getChasePeriodInfo($param);
        break;
    case 'chase_record':
        $np               = NoBadStr($_REQUEST['np']); // 当前页码
        $page             = array('np' => $np ? $np : 1,);
        $res              = getChaseOrderData($param, $page);
        break;
    case 'chase_detail':
        $res              = getChaseDetailInfo(array('oid' => NoBadStr($_REQUEST['oid'])));
        break;
    case 'ying_kui':
        $res              = profitAndLoss($param);
        break;
    case 'money_log':
        // 代理查询下级用户的账户明细，重设目标uid
        $isagent       = $_REQUEST['isagent'];
        $appoint_uid   = $_REQUEST['appoint_uid'];
        if ($isagent){
            $param['appoint_uid'] = $appoint_uid;
            $param['isagent']     = $isagent;
        }
        $res              = getMoneyLog($param);
        break;
    case 'bet_page_common':
        $param['lott_id'] = NoBadStr($_REQUEST['lott_id']);
        $res              = getBetPageRightData($param);
        break;
    case 'discover':
        // web端发现，获取数据的方式有点不一样
        
        break;
    case 'user_postal':
        $res              = getUserPostalData($param);
        $res['userInfo']  = array('username' => $_user['username'], 'accountMoney' => $_user['money']);
        break;
    case 'apply_postal':
        $param['money']   = NoBadStr($post->money);
        $param['security']= NoBadStr($post->security);
        $param['bank_id'] = NoBadStr($post->bank_id);
        if($post->platform){
            $param['platform'] = 1;
        }
        $res              = postApplyPostal($param);
        break;
    case 'setpic':
        $param['pid']     = NoBadStr($_REQUEST['pid']);
        $res              = updateUserHeadPic($param);
        $res['status']    = 'success';
        break;
    case 'setUserInfo':
        $arr = array();
        if($post->nickname) $arr['nickname'] = $post->nickname;
        if($post->gender)   $arr['gender']   = $post->gender;
        if($post->head_pic) $arr['head_pic'] = $post->head_pic;
        $arr['id']        = $_uid;
        $res = updateUserInfo($arr);
        break;
    case 'getMemberInfo':
        $res['memberInfo'] = $_user;
        if($post->uid){
            // 如果有指定用户id，则查询数据库，未指定则more自己
            $res = getUserInfo(array('uid' => $post->uid));
        }
        break;
    case 'updateUserInfo':
        // 更新用户统一使用方式
        $param     = $post->data;
        foreach ($post->data as $k => $v){
            $arr[$k] = $v;
        }
        $arr['id'] = $_uid;
        $res       = updateUserInfo($arr);
        break;
    case 'getUserBankCardList':
        $res          = getBankCardList($param);
        break;
    case 'unBindBankCard':
        $param['bid'] = NoBadStr($post->bid);
        $res          = unBindBankCart($param);
        break;
    case 'userBindBankCard':
        $post->data->bank     = NoBadStr($post->data->bank);
        $post->data->province = NoBadStr($post->data->province);
        $post->data->city     = NoBadStr($post->data->city);
        $post->data->truename = NoBadStr($post->data->truename);
        $post->data->bankcard = NoBadStr($post->data->bankcard);
        $post->data->security = NoBadStr($post->data->security);
        $param['param'] = $post->data;
        $res            = userBindBankCard($param);
        break;
    case 'getPerInfo':
        // 获取指定期号的详细信息（暂时 ， 获取开奖）
        $param['pid'] = NoBadStr($post->pid);
        $res          = getPerInfo($param);
        break;
    case 'createRps':
        // 代理用户创建邀请码
        $param['rps'] = $post->rps;
        $param['type']= $post->type;
        $res          = createRepointOdds($param);
        break;
    case 'getRpsByUid':
        $uid          = $post->uid ? $post->uid : $_uid;
        $type         = $post->type;
        $res          = getRpsByUid($uid, $type);
        break;
    case 'deleteRps':
        $param['delid'] = $post->id;
        $res          = delRpsById($param);
        break;
    case 'getInvCodeList':
        $param['uid']  = $post->uid ? $post->uid : $_uid;
        $param['type'] = $post->type;
        $res           = getInvCodeList($param);
        break;
    case 'getUserLine':
        $userLineData  = array();
        $param['uid']  = $post->uid ? $post->uid : $_uid;
        getUserLine($param['uid'], $userLineData);
        $res           = $userLineData;
        break;
    case 'getAgentReport':
        $param['timeLine'] = $post->timeLine;
        $param['forUser']  = $post->forUser;
        getUserLine($param['uid'], $userLineData);
        $param['agentUserLine'] = $userLineData;
        $res               = getAgentReport($param);
        break;
    default:
        break;
}
echo json_encode($res);




